﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankSystem.Forms
{
    public partial class LoginForm : Form
    {
        ParentForm parentForm;
        bool initialized = false;

        public LoginForm(ParentForm form)
        {
            InitializeComponent();
            this.MdiParent = form;
            parentForm = form;
            WindowState = FormWindowState.Normal;
            MaximizeBox = false;
            Dock = DockStyle.Fill;
        }

        /// <summary>
        /// 创建项目时窗体信息初始化
        /// </summary>
        /// <param name="atmInfo"></param>
        public void init(List<string>atmInfo)
        {
            textBoxID.Text = "";
            textBoxPassword.Text = "";
            if (!initialized)
            {
                initialized = true;
                foreach (string atm in atmInfo)
                {
                    comboBoxChooseATM.Items.Add(atm);
                }
            }
        }

        /// <summary>
        /// 点击退出后仅部分窗体信息初始化
        /// </summary>
        public void init()
        {
            textBoxID.Text = "";
            textBoxPassword.Text = "";
        }

        private void buttonConfirm_Click(object sender, EventArgs e)
        {
            bool findAccount = parentForm.login(textBoxID.Text, textBoxPassword.Text, comboBoxChooseATM.Text);
            if(findAccount)
            {
                parentForm.jumpToMainForm(this);
            }
        }
    }
}
